package com.xinhe.web.reposity;

import com.xinhe.web.entity.Address;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface AddressRepository  extends JpaRepository<Address, Long> {
    @Query(value = "select * from tb_address where removed = 0 and f_user_id =?1 ", nativeQuery = true)
    List<Address> findByUserId(Long userId);
    @Query(value = "select * from tb_address where removed = 0 and is_default=1 and a.f_user_id =?1 order by a.create_time desc", nativeQuery = true)
    Address findByUserIdOrderByIsDefaultDesc(Long aLong);
    @Query(value = "select * from tb_address where removed = 0 and id =?1 ", nativeQuery = true)
    Address findByAddress(Long addressId);
}
